package com.example.weblending.domain.statistics;

import com.example.weblending.vo.AnalyzeColumn;
import com.example.weblending.vo.CsvInputColumn;

public class EmploymentLength extends StatisticsBase{

    @Override
    public void init() {
        this.field.add(new StatisticsField("1"));
        this.field.add(new StatisticsField("2"));
        this.field.add(new StatisticsField("3"));
        this.field.add(new StatisticsField("4"));
        this.field.add(new StatisticsField("5"));
        this.field.add(new StatisticsField("6"));
        this.field.add(new StatisticsField("7"));
        this.field.add(new StatisticsField("8"));
        this.field.add(new StatisticsField("9"));
        this.field.add(new StatisticsField("10"));
        this.field.add(new StatisticsField("10+"));
        this.reverse=true;
    }

    @Override
    public void insert(AnalyzeColumn cleanColumn) {
        set(cleanColumn.getEmploymentLength(),cleanColumn.getIs(),cleanColumn);
    }
    @Override
    public void set(int num, float percent, CsvInputColumn column){
        int index=0;
        if (num==0){
            index=0;
        }
        else if (num>10){
            this.add(11,percent);
            index=11;

        }
        else if (num==10){
            this.add(10,percent);
            index=10;
        }
        else if (num==9){
            this.add(9,percent);
            index=9;
        }
        else if (num==8){
            this.add(8,percent);
            index=8;
        }
        else if (num==7){
            this.add(7,percent);
            index=7;
        }
        else if (num==6){
            this.add(6,percent);
            index=6;
        }
        else if (num==5){
            this.add(5,percent);
            index=5;
        }
        else if (num==4){
            this.add(4,percent);
            index=4;
        }
        else if (num==3){
            this.add(3,percent);
            index=3;
        }
        else if (num==2){
            this.add(2,percent);
            index=2;
        }
        else{
            this.add(1,percent);
            index=1;
        }
        if(this.reverse){
            index = field.size()-index+1;
        }
        column.setEmploymentLength(index);
    }
}
